home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compendium Deluxe 2
/
LSD and 17bit Compendium Deluxe - Volume II.iso
/
a
/
prog
/
asmsrc
/
thesource-7.lha
/
Source
/
DefFunc.lha
/
DefFunc
/
dfctoken.3
< prev
next >
Wrap
Text File
|
1993-12-14
|
5KB
|
199 lines
DEFUNC(3) C LIBRARY FUNCTIONS DEFUNC(3)
NAME
getarguname, nameargu, namefnct, namecnst, clrfnct,
clrfnctall, clrcnst, clrcnstall -- _d_e_f_u_n_c external token
management functions.
SYNOPSIS
#include <defunc.h>
char* getarguname(int arguidx);
int nameargu(char* argu1, char* argu2);
int namefnct(char* name, double (*fn)());
int namecnst(char* name, double);
int clrfnct(char* name);
int clrfnctall(void);
int clrcnst(char* name);
int clrcnstall(void);
DESCRIPTION
These functions are used in managing the global external
token table. _d_e_f_u_n_c function _d_f_o_p_e_n() parse an expression
based on the tokens it recognized. Except for numerical
string constant tokens(i.e. anonymous constant tokens) and 8
build in tokens "+", "-", "*", "/", "^", "(", ")", "," plus
a pseudo token "=", all other tokens are external tokens.
External tokens are usually be putted into a global token
table by user. They include 2 argument tokens, function
tokens and named constant tokens. They can be set/reset or
added/deleted statically as well as dynamically.
_g_e_t_a_r_g_u_n_a_m_e() return the name of specific argument token.
This will be useful after the argument tokens have been
reset. On success, _g_e_t_a_r_g_u_n_a_m_e() return a char pointer to
the name string. On error, e.g. a illegal argument index be
passed, it will return 0 pointer.
_n_a_m_e_a_r_g_u() resets 2 arguments tokens. In _d_e_f_u_n_c, the default
token names for the 1st and 2nd arguments are "x" and "y".
A legal token name should start with alphabetic character
and followed by alphabetic or numberic characters. The
length of a name is limited to 31 by _d_e_f_u_n_c. _n_a_m_e_a_r_g_u() will
return (int)1 on success, (int)(-1) on error and (int)0 on
no change. _d_e_f_u_n_c also provides an easy way to change the
argument names directly from the expression passed to
_d_f_o_p_e_n() (see _d_e_f_u_n_c(_3) ).
_n_a_m_e_f_n_c_t() Add a function token to the external token table.
If another token with the same name has already in the
table, then the old one will be overlapped except for it is
a argument token. Argument token items can only be
defunc 1.2 Last change: 1993 1
DEFUNC(3) C LIBRARY FUNCTIONS DEFUNC(3)
overlapped by new arguments setting. After a function token
being successfully put into the token table, it can be used
in any _d_e_f_u_n_c expressions. _n_a_m_e_f_n_c_t() will return (int)1 on
success, (int)(-1) on error and (int)0 on no changing.
_d_e_f_u_n_c also provides a dynamically way to expand the token
table with dynamically constructed functions directly from
expression passed to _d_f_o_p_e_n(). (see _d_f_o_p_e_n(_3) ).
_n_a_m_e_c_n_s_t() puts a constant token into the token table. This
will short the long expression in writting some special con-
stant. e.g.
namecnst("pi", 2.0*asin(1.0));
will add the name-constant association ("pi", 3.1415926...)
into the table. After that, the symbol "pi" can be used in
_d_e_f_u_n_c expression as a constant. Same as _n_a_m_e_f_n_c_t(),
_n_a_m_e_c_n_s_t() can overlap an old function or constant token
item but can't overlap an argument token item. _n_a_m_e_c_n_s_t()
will return (int)1 on success, (int)(-1) on error and (int)0
on no changing. Like argument and function, _d_e_f_u_n_c also pro-
vides an way to expand token table with new constant token
item at runtime (see _d_f_o_p_e_n() ).
_c_l_r_f_n_c_t(), _c_l_r_f_n_c_t_a_l_l(), _c_l_r_c_n_s_t(), _c_l_r_c_n_s_t_a_l_l() can be used
to delete a specific token or specific token type from the
token table.
SEE ALSO
_d_e_f_u_n_c, dfopen(3)
EXAMPLES
nameargu("re", "im");
This will reset argument tokens to "re" and "im" (the
default is "x" and "y").
namefnct("log", log);
namefnct("ln" , log);
This will add external function log() into token list with 2
alias names "log" and "ln".
namecnst("pi", 2.0*asin(1.0));
namecnst("PI", 2.0*asin(1.0));
This will put a named constant token into the token table
with value 3.14159... and 2 alias names "pi" and "PI".
AUTHOR
Ke Jin
Physics Department
defunc 1.2 Last change: 1993 2
DEFUNC(3) C LIBRARY FUNCTIONS DEFUNC(3)
Queen's University
Kingston, Ontario
Canada K7L 3N6
jinke@sparky.phy.queensu.ca
BUGS
Report bugs of _d_e_f_u_n_c library to the author by email.
defunc 1.2 Last change: 1993 3